#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

const int N = 2010, M = 10010;
int f[N][M][2];
int w[N], v[N];
int n, m, k;

int main() {

    cin >> n >> m >> k;
    for (int i = 1; i <= n; ++i) cin >> v[i] >> w[i];


    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j <= m; ++j) {
            f[i][j][0] = f[i - 1][j][0];
            f[i][j][1] = f[i - 1][j][1];
            if (j >= v[i]) {
                f[i][j][0] = max(f[i][j][0], f[i - 1][j - v[i]][0] + w[i]);
                f[i][j][1] = max(f[i][j][1], f[i - 1][j - v[i]][1] + w[i]);
            }
            if (j >= v[i] + k) f[i][j][1] = max(f[i][j][1], f[i - 1][j - v[i] - k][0] + 2 * w[i]);
        }
    }
    int res = 0;
    for (int i = 0; i <= m; ++i) {
        res = max({f[n][i][1], f[n][i][0], res});
    }
    cout << res;

    return 0;
}